﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using MovieRental.Entities;

namespace MovieRental.EfRepositoryLibrary.Mappers
{
    public class MediaTypeMapper : BaseMapper<MediaTypeInfo, Guid, MediaType, MediaType, MovieRentalEntitiesContainer>
    {
        public override void Convert(MediaTypeInfo entity, MediaType model)
        {
            model.Id = entity.Id;
            model.Name = entity.Name;
            model.DefaultPricePerDay = entity.DefaultPrice;
        }

        public override void ConvertBack(MediaType model, MediaTypeInfo entity)
        {
            entity.Id = model.Id;
            entity.Name = model.Name;
            entity.DefaultPrice = model.DefaultPricePerDay;
        }

        public override Guid SelectKey(MediaType model)
        {
            return model.Id;
        }

        public override Guid SelectKey(MediaTypeInfo entity)
        {
            return entity.Id;
        }

        public override ObjectSet<MediaType> SelectObjectSet(MovieRentalEntitiesContainer context)
        {
            return context.MediaTypes;
        }
    }
}
